package com.custom;


import com.custom.source.ClinkSourceSplit;
import lombok.ToString;

/**
 * 具体的数据分片类
 */
@ToString
public class MySplit implements ClinkSourceSplit {

    private final long to;
    private final int splitId;
    private long from;


    public MySplit(int splitId, long from, long to) {
        this.splitId = splitId;
        this.from = from;
        this.to = to - 1;
    }

    public boolean hasNext() {
        return from <= to;
    }

    public long getNext() {
        return from++;
    }

    @Override
    public String splitId() {
        return String.valueOf(splitId);
    }
}
